public class Test4 {
    //先根节点，然后左子树，然后右子树
    public boolean isValidBST(TreeNode root) {
        if (root == null){
            return false;
        }
        if ((root.left.val < root.val) && (root.right.val > root.val)){
            return true;
        }
        isValidBST(root.left);
        isValidBST(root.right);
        return true;
    }

    public static void main(String[] args) {
        CreatBT c = new CreatBT();
        Test4 t = new Test4();
        int[] nums = {5,1,4,0,0,3,6};
        TreeNode root = c.creatBinaryTree(nums);
        System.out.println(t.isValidBST(root));
    }
}
